package com.caidan.security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/user")
public class HelloController {
    @GetMapping
    public String test(){
        return "test1";
    }
    @GetMapping("user1")
    @PreAuthorize("hasRole('admin')")
    public  String test1(){
        log.info("输出需要的内容");
        return "hello world";
    }
}
